package com.ag.zrt.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbLogPlanStep;
import com.ag.common.BaseAction;
import com.ag.common.EventUtil;
import com.ag.zrt.service.IPlanStepService;
@Controller("eventPlanAction")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class EventPlanAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3900014152847002241L;

	private String eventPlanId;
	private TbLogPlanStep logPlanStep;
	private List<TbLogPlanStep> logPlanStepList;
	@Resource(name = "PlanStepService")
	private IPlanStepService planStepService;
	private String eventId;

	public String getEventId() {
		return eventId;
	}

	public void setEventId(String eventId) {
		this.eventId = eventId;
	}

	public void setPlanStepService(IPlanStepService planStepService) {
		this.planStepService = planStepService;
	}

	public List<TbLogPlanStep> getLogPlanStepList() {
		return logPlanStepList;
	}

	public TbLogPlanStep getLogPlanStep() {
		return logPlanStep;
	}

	public String getEventPlanId() {
		return eventPlanId;
	}

	public void setEventPlanId(String eventPlanId) {
		this.eventPlanId = eventPlanId;
	}

	public String load() {

		if (getSession().getAttribute(EventUtil.PROCESSING_EVENT_ID) != null
				&& getSession().getAttribute(
						EventUtil.PROCESSING_PLAN_ID) != null) {
			eventId = (String) getSession().getAttribute(
					EventUtil.PROCESSING_EVENT_ID);
			//eventId = "1010011001";
			System.out
					.println(eventId
							+ "/-/-*/-*/-*/-*/get eventId-*/-*/*--*/-*/-*/-*/-*/-*/-*/-*-*/-/-*");

			eventPlanId = (String) getSession().getAttribute(
					EventUtil.PROCESSING_PLAN_ID);
			//eventPlanId = "1000000001";
			System.out
					.println(eventPlanId
							+ "/-/-*/-*/-*/-*/get eventPlanId-*/-*/*--*/-*/-*/-*/-*/-*/-*/-*-*/-/-*");
		}
		if(eventId != null && eventPlanId != null){
			try {
				System.out.println(eventId+"**eventId*******************************succ_enter***********************************eventPlanId***"+eventPlanId);
				if (planStepService.checkEventIfOnDealing(eventId) == "null") {
					logPlanStepList = planStepService.findByProperty(
							"tbPlan.PId", eventPlanId, eventId);
				}
				System.out.println(eventId+"**eventId*******************************succ_out***********************************eventPlanId***"+eventPlanId);
				// ProcessingPlans.processingPlans.add(logPlanStepList);
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
		
		else{
			System.out.println("***********************************************************");
			System.out.println("传入的事件ID或预案ID为空//////eventId = "+eventId+"eventPlanId = "+eventPlanId);
			System.out.println("***********************************************************");
		}

		return "getLogPlanStepSucc";

	}
}
